﻿Imports System.ComponentModel
Public Class frmMain
    Dim excel As HocSinh_Export_Import = New HocSinh_Export_Import
    Dim excel1 As Lop_Export_Import = New Lop_Export_Import
    Dim excel2 As Khoi_Export_Import = New Khoi_Export_Import
    Dim excel3 As MonHoc_Export_Import = New MonHoc_Export_Import
    Dim excel4 As BaoCao_Export_Import = New BaoCao_Export_Import
    Dim excel5 As KetQua_Export_Import = New KetQua_Export_Import
    Public Shared dttm As New BindingList(Of HocSinhDTO)
    Public Shared dttm1 As New BindingList(Of LopDTO)
    Public Shared dttm2 As New BindingList(Of KhoiDTO)
    Public Shared dttm3 As New BindingList(Of MonHocDTO)
    Public Shared dttm4 As New BindingList(Of BaoCaoDTO)
    Public Shared dttm5 As New BindingList(Of KetQuaDTO)
    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'load UserControl Học sinh
        UsrCtrlHocSinh1.LoadDaTa()
        UsrCtrlHocSinh1.LoadLop()
        UsrCtrlHocSinh1.LoadLuaChon()
        'load UserControl lớp
        UsrCtrlLopHoc1.LoadCBXChon()
        UsrCtrlLopHoc1.LoadCBXKhoi()
        UsrCtrlLopHoc1.LoadDaTa()
        'load Khoi
        UsrCtrlKhoi1.LoadData()
        'load môn học
        UsrCtrlMonHoc1.LoadDaTa()
        'load học kỳ
        UsrCtrlHocKy1.LoadCBXHocKy()
        UsrCtrlHocKy1.LoadCBXNamHoc()
        UsrCtrlHocKy1.LoadDaTa()
        'load báo cáo
        UsrCtrlBaoCao1.LoadCBXHocKy()
        UsrCtrlBaoCao1.LoadCBXLop()
        UsrCtrlBaoCao1.LoadCBXMonHoc()
        UsrCtrlBaoCao1.LoadCBXNamHoc()
        UsrCtrlBaoCao1.LoadData()
        'load ket qua
        UsrCtrlKetQua1.LoadDaTa()
        UsrCtrlKetQua1.LoadHocKy()
        UsrCtrlKetQua1.LoadLuaChon()
        UsrCtrlKetQua1.LoadMonHoc()
    End Sub

    Private Sub btnExxport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExxport.Click
        Dim hs As New HocSinhBUS
        dttm = hs.GetList()
        excel.Export(dttm, "Danh sach", "Danh sách học sinh")
    End Sub

    Private Sub btnImportHS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImportHS.Click
        Dim ofd As New OpenFileDialog()
        If ofd.ShowDialog() = DialogResult.OK Then
            DataGridView1.DataSource = excel.ImportDSHS(ofd.FileName)
        End If
    End Sub

    Private Sub btnImportLop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImportLop.Click
        Dim ofd As New OpenFileDialog()
        If ofd.ShowDialog() = DialogResult.OK Then
            DataGridView1.DataSource = excel1.ImportDSLop(ofd.FileName)
        End If
    End Sub

    Private Sub btnExportLop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExportLop.Click
        Dim lp As New LopBUS
        dttm1 = lp.GetList()
        excel1.ExportLop(dttm1, "Danh sach", "Danh sách Lớp")
    End Sub

    Private Sub btnExxportKhoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExxportKhoi.Click
        Dim kh As New KhoiBUS
        dttm2 = kh.GetList()
        excel2.ExportKhoi(dttm2, "Danh sach", "Danh sách Khối")
    End Sub

    Private Sub btnImportKhoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImportKhoi.Click
        Dim ofd As New OpenFileDialog()
        If ofd.ShowDialog() = DialogResult.OK Then
            DataGridView1.DataSource = excel2.ImportDSKhoi(ofd.FileName)
        End If
    End Sub

    Private Sub btnImportMonhoc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImportMonhoc.Click
        Dim ofd As New OpenFileDialog()
        If ofd.ShowDialog() = DialogResult.OK Then
            DataGridView1.DataSource = excel3.ImportDSMonhoc(ofd.FileName)
        End If
    End Sub

    Private Sub btnExportmh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExportmh.Click
        Dim mh As New MonHocBUS
        dttm3 = mh.GetList()
        excel3.ExportMonHoc(dttm3, "Danh sach")
    End Sub

    Private Sub btnExportBaoCao_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExportBaoCao.Click
        Dim bc As New BaoCaoBUS
        dttm4 = bc.GetList()
        excel4.ExportBaoCao(dttm4, "Danh sach")
    End Sub

    Private Sub btnImportBaoCao_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImportBaoCao.Click
        Dim ofd As New OpenFileDialog()
        If ofd.ShowDialog() = DialogResult.OK Then
            DataGridView1.DataSource = excel4.ImportDSBaoCao(ofd.FileName)
        End If
    End Sub


    Private Sub btnExportKQ_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExportKQ.Click
        Dim kq As New KetQuaBUS
        dttm5 = kq.GetList()
        excel5.ExportKetQua(dttm5, "Danh sach")
    End Sub

    Private Sub btnimportKetQua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnimportKetQua.Click
        Dim ofd As New OpenFileDialog()
        If ofd.ShowDialog() = DialogResult.OK Then
            DataGridView1.DataSource = excel5.ImportDSKetQua(ofd.FileName)
        End If
    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        Me.Close()
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Me.Close()
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Me.Close()
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Me.Close()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Me.Close()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Close()
    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
    End Sub
End Class